package com.example.utils;

import android.widget.ImageView;

import java.util.concurrent.BlockingQueue;

public class BitmapDispathcher extends Thread{

    private BlockingQueue<BitmapRequest> requestQueue;
    public BitmapDispathcher (BlockingQueue<BitmapRequest> requestQueue){
        this.requestQueue = requestQueue;
    }
    @Override
    public void run() {
        super.run();
        //从队列中获取图片请求
        try {
            BitmapRequest request = requestQueue.take();
            //先设置占位图片
            showLoadingImage(request);
            //去网络上获取图片
            //图片显示到你的ImageView上
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

    }

    private void showLoadingImage(BitmapRequest request) {
        if (request.getLoadingResId() > 0 ){
         //   ImageView imageView = request.getImageView();
        }
    }
}
